<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" import="java.util.*" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>欢迎使用</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
	<meta name="author" content="Muhammad Usman">
	<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
	<script src="js/jquery.colorbox.js"></script>

	<!-- The styles -->
	<link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
	<style type="text/css">
	  body {
		padding-bottom: 40px;
	  }
	  .sidebar-nav {
		padding: 9px 0;
	  }
	</style>
	<link href="css/bootstrap-responsive.css" rel="stylesheet">
	<link href="css/charisma-app.css" rel="stylesheet">
	<link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet">
	<link href='css/fullcalendar.css' rel='stylesheet'>
	<link href='css/fullcalendar.print.css' rel='stylesheet'  media='print'>
	<link href='css/chosen.css' rel='stylesheet'>
	<link href='css/uniform.default.css' rel='stylesheet'>
	<link href='css/colorbox.css' rel='stylesheet'>
	<link href='css/jquery.cleditor.css' rel='stylesheet'>
	<link href='css/jquery.noty.css' rel='stylesheet'>
	<link href='css/noty_theme_default.css' rel='stylesheet'>
	<link href='css/elfinder.min.css' rel='stylesheet'>
	<link href='css/elfinder.theme.css' rel='stylesheet'>
	<link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
	<link href='css/opa-icons.css' rel='stylesheet'>
	<link href='css/uploadify.css' rel='stylesheet'>

	<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
	<!--[if lt IE 9]>
	  <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
	<![endif]-->

	<!-- The fav icon -->
	<link rel="shortcut icon" href="img/favicon.ico">
		
</head>

<body>
		<!-- topbar starts -->
	<div class="navbar">
		<div class="navbar-inner">
			<div class="container-fluid">
				<a class="btn btn-navbar" data-toggle="collapse" data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</a>
				<a class="brand" href="index.jsp"> <img alt="Charisma Logo" src="img/logo20.png" /> <span>Manage</span></a>
				
				<!-- theme selector starts -->
				<div class="btn-group pull-right theme-container" >
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						<i class="icon-tint"></i><span class="hidden-phone"> Change Theme / Skin</span>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu" id="themes">
						<li><a data-value="classic" href="#"><i class="icon-blank"></i> Classic</a></li>
						<li><a data-value="cerulean" href="#"><i class="icon-blank"></i> Cerulean</a></li>
						<li><a data-value="cyborg" href="#"><i class="icon-blank"></i> Cyborg</a></li>
						<li><a data-value="redy" href="#"><i class="icon-blank"></i> Redy</a></li>
						<li><a data-value="journal" href="#"><i class="icon-blank"></i> Journal</a></li>
						<li><a data-value="simplex" href="#"><i class="icon-blank"></i> Simplex</a></li>
						<li><a data-value="slate" href="#"><i class="icon-blank"></i> Slate</a></li>
						<li><a data-value="spacelab" href="#"><i class="icon-blank"></i> Spacelab</a></li>
						<li><a data-value="united" href="#"><i class="icon-blank"></i> United</a></li>
					</ul>
				</div>
				<!-- theme selector ends -->
				
				<!-- user dropdown starts -->
				<div class="btn-group pull-right" >
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						<i class="icon-user"></i><span class="hidden-phone"> 欢迎 <%=session.getAttribute("username") %></span>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a class='inline' href="#inline_content">修改密码</a></li>
						<li><a href="forward.jsp">切换身份</a></li>
						<li class="divider"></li>
						<li><a href="login.html">退出</a></li>
					</ul>
				</div>
				<!-- user dropdown ends -->
				
				<div class="top-nav nav-collapse">
					<ul class="nav">
						<li><a href="#">Visit Site</a></li>
						<li>
							<form class="navbar-search pull-left">
								<input placeholder="Search" class="search-query span2" name="query" type="text">
							</form>
						</li>
					</ul>
				</div><!--/.nav-collapse -->
			</div>
		</div>
	</div>
	<!-- topbar ends -->
		<div class="container-fluid">
		<div class="row-fluid">
				
			<!-- left menu starts -->
			<div class="span2 main-menu-span">
				<div class="well nav-collapse sidebar-nav">
					<ul class="nav nav-tabs nav-stacked main-menu">
						<li class="nav-header hidden-tablet">主菜单</li>
						<li><a class="ajax-link" href="subject.jsp"><i class="icon-home"></i><span class="hidden-tablet"> 创建课程</span></a></li>
						<li><a class="ajax-link" href="class.jsp"><i class="icon-eye-open"></i><span class="hidden-tablet"> 创建班级</span></a></li>
						<li><a class="ajax-link" href="cron.jsp"><i class="icon-edit"></i><span class="hidden-tablet"> 创建任务</span></a></li>
						<li><a class="ajax-link" href="query.jsp"><i class="icon-list-alt"></i><span class="hidden-tablet"> 查看考勤</span></a></li>
						<li class="nav-header hidden-tablet">待开发</li>
						<li><a class="ajax-link" href="index.jsp"><i class="icon-font"></i><span class="hidden-tablet"> 功能待定</span></a></li>
						<li><a class="ajax-link" href="index.jsp"><i class="icon-picture"></i><span class="hidden-tablet"> 功能待定</span></a></li>
						
					</ul>
					<label id="for-is-ajax" class="hidden-tablet" for="is-ajax"><input id="is-ajax" type="checkbox"> Ajax on menu</label>
				</div><!--/.well -->
			</div><!--/span-->
			<!-- left menu ends -->
			
			<noscript>
				<div class="alert alert-blo ck span10">
					<h4 class="alert-heading">Warning!</h4>
					<p>You need to have <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a> enabled to use this site.</p>
				</div>
			</noscript>
			
			<div id="content" class="span10">
			<!-- content starts -->
				<form action="export" method="post" id="form">
					<table border="0" id="table1">
						<tr>
							<td>
								<label>选择学年：</label><select id="selectYear" name="year"></select>
							</td>
							<td>
								<label>选择学期：</label>
			       				<select id="selectSemester" name="semester" onchange="getSubject('selectYear', 'selectSemester', 'selectSubject')">
			       					<option value="void">请选择</option>
			       					<option value="1">1</option>
			       					<option value="2">2</option>
			       				</select>
							</td>
							<td>
								<label>选择课程：</label>
       							<select id="selectSubject" name="subject" onchange="getClass('selectSubject','selectClass')"></select>
							</td>
							<td>
								<label>选择班级：</label>
       							<select id="selectClass" name="class" onchange="getData('selectClass')">
       							</select>
							</td>
							<td>
								<a href="#" onclick="change()">统计</a>
							</td>
							<td>
								<a href="#" id="export" style="display: none" onclick="downloadExcel()">下载考勤记录</a>
							</td>
						</tr>
					</table>
					<a id="button" href="#inline_content_count" class="inline" style='display:none'>
						<input type="button" value="统计" 
						onclick="queryCount('selectStartDate','selectEndDate','selectSubject')">
					</a>
					<img alt="" src="img/loading-a.gif" id="loading" style="display: none;">
					<div class="row-fluid sortable" id="display_space" style="display: none;">		
						<div class="box span12">
							<div class="box-header well" data-original-title>
								<h2><i class="icon-user"></i> 考勤记录</h2>
								<div class="box-icon">
									<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
									<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
									<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
								</div>
							</div>
							<div style="overflow-x: auto; overflow-y: auto; height: 300px; width:100%;">
								<table class="table table-striped table-bordered bootstrap-datatable">
									<thead>
										  <tr>
											  <th style='white-space: nowrap'>学号</th>
											  <th style='white-space: nowrap'>姓名</th>
											  <th style='white-space: nowrap'>性别</th>
											  <th style='white-space: nowrap'>班级</th>
											  <th style='white-space: nowrap'>缺勤/迟到/总次数</th>
											  <th style='white-space: nowrap'>考勤时间</th>
										  </tr>
									</thead>
									<tbody id="query_details">
									</tbody>
								</table>
							</div>
						</div><!--/span-->
					</div><!--/row-->
				</form>
       			<!-- This contains the hidden content for inline calls -->
				<div style='display:none'>
					<div id='inline_content' style='padding:10px; background:#fff;'>
							<div>
								<table>
									<tr>
										<td><label>原密码:</label></td>
										<td><input type="password" id="oldPassword" /></td>
									</tr>
									<tr>
										<td><label>新密码:</label></td>
										<td><input type="password" id="newPassword" /></td>
									</tr>
									<tr>
										<td><label>确认密码:</label></td>
										<td><input type="password" id="confirmPassword" /></td>
									</tr>
								</table>
								<input type="submit" value="修改"
									onclick="changePasswd('oldPassword','newPassword','confirmPassword')" />
							</div>
					</div>
					<div id='inline_content_count' style='padding:10px; background:#fff;'>
						<table class="table table-striped table-bordered bootstrap-datatable">
							<thead>
								  <tr>
									  <th>班级</th>
									  <th>缺勤情况</th>
								  </tr>
							</thead>
							<tbody id="query_count">
							</tbody>
						</table>
					</div>
				</div>
				<script type="text/javascript">
					$(document).ready(function() {
						$(".inline").colorbox({
							inline : true,
							width : "50%"
						});
					});
					//Ajax提交修改密码
					function changePasswd(frist_type_id, second_type_id,
							third_type_id) {
						var frist = document.getElementById(frist_type_id);
						var second = document.getElementById(second_type_id);
						var third = document.getElementById(third_type_id);
						var oldPasswd = frist.value;
						var newPasswd = second.value;
						var confirmPasswd = third.value;
						if (newPasswd == confirmPasswd) {
							$.post('changePassword', {
								'oldPassword' : oldPasswd,
								'newPassword' : newPasswd,
								'confirmPassword' : confirmPasswd
							}, function(data, textStatus) {
								var dataArray = JSON.parse(data);
								alert(dataArray.msg);
							});
						} else {
							alert("您输入的密码和确认密码不一致！");
						}
						frist.value = "";
						second.value = "";
						third.value = "";
					}
				</script>
				<script type="text/javascript">
	       			//初始化学期信息
	   				$("selectYear").ready(function(){
	   					var select = document.getElementById("selectYear");
	   					$.post("queryYear",{},function(data, textStatus){
	   						var dataArray = JSON.parse(data);
	   						select.options.add(new Option("请选择", "void"));
	   						for(var i=0;i<dataArray.length;i++){
	   							select.options.add(new Option(dataArray[i], dataArray[i]));
	   						}
	   					});
	   				});
	   				/* //初始化学院信息
	       			$("selectInstitute").ready(function(){
	       				var select = document.getElementById("selectInstitute");
	       				$.post("queryInstitute",{},function(data,textStatus){
	       					var dataArray = JSON.parse(data);
	       					select.options.add(new Option("请选择", "void"));
	   						for(var i=0;i<dataArray.length;i++){
	   							select.options.add(new Option(dataArray[i].institute, dataArray[i].id));
	   						}
	       				});
	       			});
	   				//Ajax刷新学院内考勤人员信息
	   				function getAccount(frist_type_id,next_sel_id){
	   					var frist_sel = document.getElementById(frist_type_id);
	   					var next_sel = document.getElementById(next_sel_id);
	   					var frist_value = frist_sel.options[frist_sel.selectedIndex].value;
	   					if (frist_value != "void") {
	   						//alert(1);
	   						$.post('queryAccount',{'teacherNumber':frist_value},function(data, textStatus){
	   							var dataArray = JSON.parse(data);
	   							next_sel.options.length = 0;
			                    next_sel.options.add(new Option("请选择", "void"));
			                    for (var i = 0; i < dataArray.length; i++) {
			                        next_sel.options.add(new Option(dataArray[i].name, dataArray[i].id));
			                    }
	   						});
	   					}
	   				} */
	   				//Ajax刷新课程信息
       				function getSubject(frist_type_id, second_type_id, next_sel_id) {
			            var sel = document.getElementById(frist_type_id);
			            var frist_type = sel.options[sel.selectedIndex].value;
			            var sel_second = document.getElementById(second_type_id);
			            var second_type = sel_second.options[sel_second.selectedIndex].value;
			            var next_sel = document.getElementById(next_sel_id);
			            next_sel.options.length = 0;
			            if (frist_type != "void") {
			                $.post('querySubject', { 'year':frist_type, 'semester':second_type}, function (data, textStatus) {
			                    var dataArray = JSON.parse(data);
			                    next_sel.options.length = 0;
			                    next_sel.options.add(new Option("请选择", "void"));
			                    for (var i = 0; i < dataArray.length; i++) {
			                        next_sel.options.add(new Option(dataArray[i].name, dataArray[i].id));
			                    }
			                });
			            }
			        };
			        //Ajax查询上课班级
			        function getClass(frist_type_id,next_sel_id){
			        	var sel = document.getElementById(frist_type_id);
			            var frist_type = sel.options[sel.selectedIndex].value;
			            var next_sel = document.getElementById(next_sel_id);
			            next_sel.options.length = 0;
			            if (frist_type != "void") {
			                $.post('queryClass2', { 'subject':frist_type }, function (data, textStatus) {
			                    var dataArray = JSON.parse(data);
			                    next_sel.options.length = 0;
			                    next_sel.options.add(new Option("请选择", "void"));
			                    for (var i = 0; i < dataArray.length; i++) {
			                        next_sel.options.add(new Option(dataArray[i].name, dataArray[i].id));
			                    }
			                });
			            }
			        }
			        function getData(frist_type_id){
			        	var frist = document.getElementById(frist_type_id);
			        	var frist_type = frist.options[frist.selectedIndex].value;
			        	$("#loading").show();	//显示loading
		        		$("#display_space").hide();	//数据区隐藏
			        	if (frist_type != "void") {
			        		$.post('queryCheckData',{'class':frist_type},function(data, textStatus){
				        		var dataArray = JSON.parse(data);
				        		//清空table
				        		$("#query_details").empty();
				        		for (var i = 0; i < dataArray.length; i++) {
				        			$("#query_details").append("<tr></tr>");
				        			var Obj = dataArray[i];
				        			for(var attributr in Obj){
				        				$("#query_details tr:eq("+i+")").append("<td style='white-space: nowrap'>"+Obj[attributr]+"</td>");
				        			}
				        		}
				        		//显示下载按钮
				        		$("#display_space").show();	//显示数据区
				        		$("#loading").hide();	//去除loading
				        		$("#export").show();
				        		$(".inline").colorbox({
									inline : true,
									//height : "100%"
								});
				        	});
			        	}
			        }
			        //查询考勤详情
			        function getDetails(object){
			        	var cronNumber = object.id;
			        	$.post('queryDetails',{'cronNumber':cronNumber},function(data, textStatus){
			        		var dataArray = JSON.parse(data);
			        		$("#query_details").empty();
			        		for (var i = 0; i < dataArray.length; i++) {
			        			$("#query_details").append("<tr></tr>");
		                        $("#query_details tr:eq("+i+")").append("<td>"+dataArray[i].id+"</td>");
		                        $("#query_details tr:eq("+i+")").append("<td class='center'>"+dataArray[i].name+"</td>");
		                        $("#query_details tr:eq("+i+")").append("<td class='center'>"+dataArray[i].sex+"</td>");
		                        $("#query_details tr:eq("+i+")").append("<td class='center'>"+dataArray[i].className+"</td>");
		                        $("#query_details tr:eq("+i+")").append("<td class='center'>"+dataArray[i].status+"</td>");
		                        $("#query_details tr:eq("+i+")").append("<td class='center'>"+dataArray[i].time+"</td>");
		                        $("#query_details tr:eq("+i+")").append("<td class='center'>"+dataArray[i].date+"</td>");
			        		}
			        	});
			        }
			        //创建统计界面
			        function change(){
			        	$("#table1 tr:eq(0) td:eq(3)").empty();
			        	$("#table1 tr:eq(0) td:eq(4)").remove();
			        	$("#table1").append("<tr><td></td><td></td></tr>");
			        	$("#table1 tr:eq(1) td:eq(0)").
			        	append("<label>开始日期：</label><input type='text' name='startDay' id='selectStartDate' readonly='readonly'/>");
			        	$("#table1 tr:eq(1) td:eq(1)").
			        	append("<label>结束日期：</label><input type='text' name='endDay' id='selectEndDate' readonly='readonly'/>");
			        	$('#selectStartDate').datepicker();
			        	$('#selectEndDate').datepicker();
			        	$('#button').show();
			        	$(".inline").colorbox({
							inline : true,
							width : "50%",
							height : "60%"
						});
			        }
			        //查询统计结果
			        function queryCount(frist_type_id,second_type_id,third_type_id){
			        	var frist_value = document.getElementById(frist_type_id).value;
			        	var second_value = document.getElementById(second_type_id).value;
			        	var third = document.getElementById(third_type_id);
			        	var third_value = third.options[third.selectedIndex].value;
			        	$("#query_count").empty();
			        	//if(frist_value<second_value){
			        	$.post('queryCount',{'startDay':frist_value,'endDay':second_value,
			        		'subjectNumber':third_value},function(data, textStatus){
			        		var dataArray = JSON.parse(data);
			        		//显示统计信息
			        		for (var i = 0; i < dataArray.length; i++) {
			        		$("#query_count").append("<tr></tr>");
		                    $("#query_count tr:eq("+i+")").append("<td class='center'>"+dataArray[i].className+"</td>");
		                    $("#query_count tr:eq("+i+")").append("<td class='center'>"+dataArray[i].info+"</td>");
			     	  		}
			        	});	
			        	//}
			        }
			      	//请求下载考勤表
			        function downloadExcel(){
			        	$("#form").submit();
			        }
       			</script>
			<!-- content ends -->
			</div><!--/#content.span10-->
				</div><!--/fluid-row-->
				
		<hr>

		<div class="modal hide fade" id="myModal">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">Ã</button>
				<h3>Settings</h3>
			</div>
			<div class="modal-body">
				<p>Here settings can be configured...</p>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal">Close</a>
				<a href="#" class="btn btn-primary">Save changes</a>
			</div>
		</div>

		<footer>
			<p class="pull-left">&copy; <a href="http://www.hyit.edu.cn/" target="_blank">淮阴工学院 计算机工程学院</a> 2014</p>
			<p class="pull-right">Powered by: <a href="https://github.com/akinoneko">HYIT</a></p>
		</footer>
		
	</div><!--/.fluid-container-->

	<!-- external javascript
	================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->

	<!-- jQuery -->
	<script src="js/jquery-1.7.2.min.js"></script>
	<!-- jQuery UI -->
	<script src="js/jquery-ui-1.8.21.custom.min.js"></script>
	<!-- transition / effect library -->
	<script src="js/bootstrap-transition.js"></script>
	<!-- alert enhancer library -->
	<script src="js/bootstrap-alert.js"></script>
	<!-- modal / dialog library -->
	<script src="js/bootstrap-modal.js"></script>
	<!-- custom dropdown library -->
	<script src="js/bootstrap-dropdown.js"></script>
	<!-- scrolspy library -->
	<script src="js/bootstrap-scrollspy.js"></script>
	<!-- library for creating tabs -->
	<script src="js/bootstrap-tab.js"></script>
	<!-- library for advanced tooltip -->
	<script src="js/bootstrap-tooltip.js"></script>
	<!-- popover effect library -->
	<script src="js/bootstrap-popover.js"></script>
	<!-- button enhancer library -->
	<script src="js/bootstrap-button.js"></script>
	<!-- accordion library (optional, not used in demo) -->
	<script src="js/bootstrap-collapse.js"></script>
	<!-- carousel slideshow library (optional, not used in demo) -->
	<script src="js/bootstrap-carousel.js"></script>
	<!-- autocomplete library -->
	<script src="js/bootstrap-typeahead.js"></script>
	<!-- tour library -->
	<script src="js/bootstrap-tour.js"></script>
	<!-- library for cookie management -->
	<script src="js/jquery.cookie.js"></script>
	<!-- calander plugin -->
	<script src='js/fullcalendar.min.js'></script>
	<!-- data table plugin -->
	<script src='js/jquery.dataTables.min.js'></script>

	<!-- chart libraries start -->
	<script src="js/excanvas.js"></script>
	<script src="js/jquery.flot.min.js"></script>
	<script src="js/jquery.flot.pie.min.js"></script>
	<script src="js/jquery.flot.stack.js"></script>
	<script src="js/jquery.flot.resize.min.js"></script>
	<!-- chart libraries end -->

	<!-- select or dropdown enhancer -->
	<script src="js/jquery.chosen.min.js"></script>
	<!-- checkbox, radio, and file input styler -->
	<script src="js/jquery.uniform.min.js"></script>
	<!-- plugin for gallery image view -->
	<script src="js/jquery.colorbox.min.js"></script>
	<!-- rich text editor library -->
	<script src="js/jquery.cleditor.min.js"></script>
	<!-- notification plugin -->
	<script src="js/jquery.noty.js"></script>
	<!-- file manager library -->
	<script src="js/jquery.elfinder.min.js"></script>
	<!-- star rating plugin -->
	<script src="js/jquery.raty.min.js"></script>
	<!-- for iOS style toggle switch -->
	<script src="js/jquery.iphone.toggle.js"></script>
	<!-- autogrowing textarea plugin -->
	<script src="js/jquery.autogrow-textarea.js"></script>
	<!-- multiple file upload plugin -->
	<script src="js/jquery.uploadify-3.1.min.js"></script>
	<!-- history.js for cross-browser state change on ajax -->
	<script src="js/jquery.history.js"></script>
	<!-- application script for Charisma demo -->
	<script src="js/charisma.js"></script>
	
		
</body>
</html>
